package Cursus.Listeners;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Swing_frame03 extends JFrame {
    private JButton but = new JButton("blabla");
    private JTextField text = new JTextField(20);
    private Swing_frame02 parent;

    public Swing_frame03(Swing_frame02 parent) {
        super("invoerscherm");
        this.parent = parent;
        Container c = this.getContentPane();
        c.setLayout(new FlowLayout());
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        c.add(but);
        c.add(new JLabel("Tekst: "));
        c.add(text);
        but.setAction(new Aktie("voegtoe aan lijst"));
        this.setVisible(true);
        this.pack();
    }

    public class Aktie extends AbstractAction {

        private int i = 0;

        public Aktie(String s) {
            super(s);
        }

        public void actionPerformed(ActionEvent ae) {
            if(ae.getSource() == but) {
                String t = text.getText();
                parent.voegtoeAanLijst(t);
            }
        }

    }
}
